package com.thiswhyme.demo.log4j2.service1;

import com.thiswhyme.demo.log4j2.service.InfoDemoService;
import com.thiswhyme.demo.log4j2.service.WarnDemoService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Service;

/**
 * @author: thiswhyme
 * @date: 2021/6/8
 */
@Slf4j
@AllArgsConstructor
@Service
public class DefaultDemoService implements ApplicationRunner {

    private final InfoDemoService infoDemoService;

    private final WarnDemoService warnDemoService;

    public void testLogs() {
        log.trace("-----trace级别日志");
        log.debug("-----debug级别日志");
        log.info("-----info级别日志");
        log.warn("-----warn级别日志");
        log.error("-----error级别日志");
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        while(true) {
            warnDemoService.testLogs();
            infoDemoService.testLogs();
            testLogs();
            Thread.sleep(5000);
        }
    }
}
